00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "OSDLCommandManager.h"
00028
00029
00030 #include "OSDLSound.h"
00031 #include "OSDLMusic.h"
00032
00033 #include "OSDLIPCCommands.h"
00034
00035 #include "OSDLARM7Codes.h"
00036
00037
00038
00039 #ifdef OSDL_USES_CONFIG_H
00040 #include "OSDLConfig.h"
00041 #endif // OSDL_USES_CONFIG_H
00042
00043
00044 #if OSDL_ARCH_NINTENDO_DS
00045 #include "OSDLConfigForNintendoDS.h"
00046 #endif // OSDL_ARCH_NINTENDO_DS
00047
00048
00049
00050
00051
00052 using namespace OSDL ;
00053 using namespace OSDL::Audio ;
00054
00055 using namespace Ceylan::Log ;
00056 using namespace Ceylan::System ;
00057
00058
00059 using std::string ;
00060
00061
00062
00063 CommandManager * CommandManager::_IPCManager = 0 ;
00064
00065
00066
00067 CommandException::CommandException( const string & reason ) :
00068 OSDL::Exception( reason )
00069 {
00070
00071 }
00072
00073
00074
00075 CommandException::~CommandException() throw()
00076 {
00077
00078 }
00079
00080
00081
00082 CommandManager::CommandManager() :
00083 FIFO(),
00084 _currentMusic(0),
00085 _doubleBuffer(0),
00086 _bufferSize(4096 * 2),
00087 _settings(0)
00088 {
00089
00090 #if OSDL_ARCH_NINTENDO_DS
00091
00092 #ifdef OSDL_RUNS_ON_ARM9
00093
00094
00095 enableMusicSupport() ;
00096
00097 if ( _IPCManager != 0 )
00098 throw CommandException( "CommandManager constructor failed: "
00099 "there is already a CommandManager instance registered" ) ;
00100
00101
00102
00103 _IPCManager = this ;
00104
00105
00106 #else // OSDL_RUNS_ON_ARM9
00107
00108 throw CommandException( "CommandManager constructor failed: "
00109 "not available on the ARM7." ) ;
00110
00111 #endif // OSDL_RUNS_ON_ARM9
00112
00113
00114 #else // OSDL_ARCH_NINTENDO_DS
00115
00116 throw CommandException( "CommandManager constructor failed: "
00117 "not available on this platform." ) ;
00118
00119 #endif // OSDL_ARCH_NINTENDO_DS
00120
00121 }
00122
00123
00124
00125 CommandManager::~CommandManager() throw()
00126 {
00127
00128
00129
00130 disableMusicSupport() ;
00131
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141 void CommandManager::playSound( Audio::Sound & sound )
00142 {
00143
00144 if ( ! sound.hasContent() )
00145 throw CommandException( "CommandManager::playSound failed: "
00146 "specified sound has no content." ) ;
00147
00148 #if OSDL_ARCH_NINTENDO_DS
00149
00150 #ifdef OSDL_RUNS_ON_ARM9
00151
00152 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00153
00154
00155
00156
00157
00158
00159 FIFOElement commandElement = prepareFIFOCommand( PlaySoundRequest ) ;
00160
00161 const Audio::LowLevelSound & actualSound = sound.getContent() ;
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 if ( actualSound._bitDepth == 8 )
00173 commandElement |= 0x00100000 ;
00174 else if ( actualSound._bitDepth == 16 )
00175 commandElement |= 0x00200000 ;
00176
00177
00178
00179 if ( actualSound._mode == 1 )
00180 commandElement |= 0x00010000 ;
00181 else
00182 commandElement |= 0x00020000 ;
00183
00184
00185
00186 commandElement |= sound.getContent()._frequency ;
00187
00188 writeBlocking( commandElement ) ;
00189
00190
00191 writeBlocking( reinterpret_cast<FIFOElement>(
00192 sound.getContent()._samples ) ) ;
00193
00194
00195 writeBlocking( static_cast<FIFOElement>( sound.getContent()._size ) ) ;
00196
00197 SetEnabledInterrupts( previous ) ;
00198
00199 notifyCommandToARM7() ;
00200
00201 #else // OSDL_RUNS_ON_ARM9
00202
00203 throw CommandException( "CommandManager::playSound failed: "
00204 "not available on the ARM7." ) ;
00205
00206 #endif // OSDL_RUNS_ON_ARM9
00207
00208
00209 #else // OSDL_ARCH_NINTENDO_DS
00210
00211 throw CommandException( "CommandManager::playSound failed: "
00212 "not available on this platform." ) ;
00213
00214 #endif // OSDL_ARCH_NINTENDO_DS
00215
00216 }
00217
00218
00219
00220 void CommandManager::enableMusicSupport()
00221 {
00222
00223 #if OSDL_ARCH_NINTENDO_DS
00224
00225 #ifdef OSDL_RUNS_ON_ARM9
00226
00227
00228 _doubleBuffer = CacheProtectedNew( _bufferSize * 2 ) ;
00229
00230 _settings = new CommandManagerSettings() ;
00231
00232 _settings->_commandManager = this ;
00233 _settings->_bufferSize = _bufferSize ;
00234 _settings->_doubleBuffer = _doubleBuffer ;
00235 _settings->_secondBuffer = _doubleBuffer + _bufferSize ;
00236
00237 Music::SetCommandManagerSettings( *_settings ) ;
00238
00239 #else // OSDL_RUNS_ON_ARM9
00240
00241 throw CommandException( "CommandManager::enableMusicSupport failed: "
00242 "not available on the ARM7." ) ;
00243
00244 #endif // OSDL_RUNS_ON_ARM9
00245
00246
00247 #else // OSDL_ARCH_NINTENDO_DS
00248
00249 throw CommandException( "CommandManager::enableMusicSupport failed: "
00250 "not available on this platform." ) ;
00251
00252 #endif // OSDL_ARCH_NINTENDO_DS
00253
00254 }
00255
00256
00257
00258 void CommandManager::disableMusicSupport()
00259 {
00260
00261 #if OSDL_ARCH_NINTENDO_DS
00262
00263 #ifdef OSDL_RUNS_ON_ARM9
00264
00265 if ( _doubleBuffer != 0 )
00266 {
00267
00268 CacheProtectedDelete( _doubleBuffer ) ;
00269 _doubleBuffer = 0 ;
00270
00271 }
00272
00273 if ( _settings != 0 )
00274 {
00275
00276 delete _settings ;
00277 _settings = 0 ;
00278
00279 }
00280
00281 #else // OSDL_RUNS_ON_ARM9
00282
00283 throw CommandException( "CommandManager::disableMusicSupport failed: "
00284 "not available on the ARM7." ) ;
00285
00286 #endif // OSDL_RUNS_ON_ARM9
00287
00288
00289 #else // OSDL_ARCH_NINTENDO_DS
00290
00291 throw CommandException( "CommandManager::disableMusicSupport failed: "
00292 "not available on this platform." ) ;
00293
00294 #endif // OSDL_ARCH_NINTENDO_DS
00295
00296 }
00297
00298
00299
00300 BufferSize CommandManager::getMusicBufferSize() const
00301 {
00302
00303 return _bufferSize ;
00304
00305 }
00306
00307
00308
00309 Ceylan::Byte * CommandManager::getMusicBuffer() const
00310 {
00311
00312 if ( _doubleBuffer == 0 )
00313 throw CommandException( "CommandManager::getMusicBuffer failed: "
00314 "no available buffer." ) ;
00315
00316 return _doubleBuffer ;
00317
00318 }
00319
00320
00321
00322 void CommandManager::playMusic( Audio::Music & music )
00323 {
00324
00325 #if OSDL_ARCH_NINTENDO_DS
00326
00327 #ifdef OSDL_RUNS_ON_ARM9
00328
00329 music.setAsCurrent() ;
00330
00331
00332 _currentMusic = & music ;
00333
00334 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00335
00336 LowLevelMusic & actualMusic = music.getContent() ;
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 FIFOElement commandElement = prepareFIFOCommand( PlayMusicRequest ) ;
00349
00350
00351 writeBlocking( ( commandElement | 0x00000001 ) ) ;
00352
00353
00354 writeBlocking( reinterpret_cast<FIFOElement>( _doubleBuffer ) ) ;
00355
00356
00357 writeBlocking( (FIFOElement) ( ( ( (Ceylan::Uint16) _bufferSize ) << 16 )
00358 | ( (Ceylan::Uint16) actualMusic._frameSizeUpperBound ) ) ) ;
00359
00360 SetEnabledInterrupts( previous ) ;
00361
00362 notifyCommandToARM7() ;
00363
00364
00365
00366
00367
00368
00369
00370 #else // OSDL_RUNS_ON_ARM9
00371
00372 throw CommandException( "CommandManager::playMusic failed: "
00373 "not available on the ARM7." ) ;
00374
00375 #endif // OSDL_RUNS_ON_ARM9
00376
00377
00378 #else // OSDL_ARCH_NINTENDO_DS
00379
00380 throw CommandException( "CommandManager::playMusic failed: "
00381 "not available on this platform." ) ;
00382
00383 #endif // OSDL_ARCH_NINTENDO_DS
00384
00385 }
00386
00387
00388
00389 void CommandManager::playMusicWithFadeIn( Audio::Music & music,
00390 Ceylan::System::Millisecond fadeInMaxDuration )
00391 {
00392
00393 #if OSDL_ARCH_NINTENDO_DS
00394
00395 #ifdef OSDL_RUNS_ON_ARM9
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405 music.setAsCurrent() ;
00406
00407
00408 _currentMusic = & music ;
00409
00410 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00411
00412 LowLevelMusic & actualMusic = music.getContent() ;
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 FIFOElement commandElement = prepareFIFOCommand( PlayMusicRequest ) ;
00425
00426
00427 writeBlocking( ( commandElement | 0x00000001 ) ) ;
00428
00429
00430 writeBlocking( reinterpret_cast<FIFOElement>( _doubleBuffer ) ) ;
00431
00432
00433 writeBlocking( (FIFOElement) ( ( ( (Ceylan::Uint16) _bufferSize ) << 16 )
00434 | ( (Ceylan::Uint16) actualMusic._frameSizeUpperBound ) ) ) ;
00435
00436
00437
00438 writeBlocking( prepareFIFOCommand( FadeInMusicRequest )
00439 | ( fadeInMaxDuration & 0x0000ffff ) ) ;
00440
00441 SetEnabledInterrupts( previous ) ;
00442
00443 notifyCommandToARM7() ;
00444
00445
00446
00447
00448
00449
00450
00451
00452 #else // OSDL_RUNS_ON_ARM9
00453
00454 throw CommandException( "CommandManager::playMusicWithFadeIn failed: "
00455 "not available on the ARM7." ) ;
00456
00457 #endif // OSDL_RUNS_ON_ARM9
00458
00459
00460 #else // OSDL_ARCH_NINTENDO_DS
00461
00462 throw CommandException( "CommandManager::playMusicWithFadeIn failed: "
00463 "not available on this platform." ) ;
00464
00465 #endif // OSDL_ARCH_NINTENDO_DS
00466
00467 }
00468
00469
00470
00471 void CommandManager::stopMusic()
00472 {
00473
00474 #if OSDL_ARCH_NINTENDO_DS
00475
00476 #ifdef OSDL_RUNS_ON_ARM9
00477
00478
00479 if ( _currentMusic == 0 )
00480 {
00481
00482 LogPlug::warning(
00483 "CommandManager::stopMusic: no current music to stop." ) ;
00484
00485 return ;
00486
00487 }
00488
00489 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00490
00491 writeBlocking( prepareFIFOCommand( StopMusicRequest ) ) ;
00492
00493 SetEnabledInterrupts( previous ) ;
00494
00495 notifyCommandToARM7() ;
00496
00497
00498
00499
00500
00501
00502
00503 #else // OSDL_RUNS_ON_ARM9
00504
00505 throw CommandException( "CommandManager::stopMusic failed: "
00506 "not available on the ARM7." ) ;
00507
00508 #endif // OSDL_RUNS_ON_ARM9
00509
00510
00511 #else // OSDL_ARCH_NINTENDO_DS
00512
00513 throw CommandException( "CommandManager::stopMusic failed: "
00514 "not available on this platform." ) ;
00515
00516 #endif // OSDL_ARCH_NINTENDO_DS
00517
00518 }
00519
00520
00521
00522 void CommandManager::fadeInMusic(
00523 Ceylan::System::Millisecond fadeInMaxDuration )
00524 {
00525
00526 #if OSDL_ARCH_NINTENDO_DS
00527
00528 #ifdef OSDL_RUNS_ON_ARM9
00529
00530
00531 if ( _currentMusic == 0 )
00532 {
00533
00534 LogPlug::warning(
00535 "CommandManager::fadeInMusic: no current music to fade-in." ) ;
00536
00537 return ;
00538
00539 }
00540
00541 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00542
00543 writeBlocking(
00544 prepareFIFOCommand( FadeInMusicRequest ) | fadeInMaxDuration ) ;
00545
00546 SetEnabledInterrupts( previous ) ;
00547
00548 notifyCommandToARM7() ;
00549
00550
00551
00552
00553
00554
00555
00556 #else // OSDL_RUNS_ON_ARM9
00557
00558 throw CommandException( "CommandManager::fadeInMusic failed: "
00559 "not available on the ARM7." ) ;
00560
00561 #endif // OSDL_RUNS_ON_ARM9
00562
00563
00564 #else // OSDL_ARCH_NINTENDO_DS
00565
00566 throw CommandException( "CommandManager::fadeInMusic failed: "
00567 "not available on this platform." ) ;
00568
00569 #endif // OSDL_ARCH_NINTENDO_DS
00570
00571 }
00572
00573
00574
00575 void CommandManager::fadeOutMusic(
00576 Ceylan::System::Millisecond fadeOutMaxDuration )
00577 {
00578
00579 #if OSDL_ARCH_NINTENDO_DS
00580
00581 #ifdef OSDL_RUNS_ON_ARM9
00582
00583
00584 if ( _currentMusic == 0 )
00585 {
00586
00587 LogPlug::warning(
00588 "CommandManager::fadeOutMusic: no current music to fade-out." ) ;
00589
00590 return ;
00591
00592 }
00593
00594 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00595
00596 writeBlocking(
00597 prepareFIFOCommand( FadeOutMusicRequest ) | fadeOutMaxDuration ) ;
00598
00599 SetEnabledInterrupts( previous ) ;
00600
00601 notifyCommandToARM7() ;
00602
00603
00604
00605
00606
00607
00608
00609 #else // OSDL_RUNS_ON_ARM9
00610
00611 throw CommandException( "CommandManager::fadeOutMusic failed: "
00612 "not available on the ARM7." ) ;
00613
00614 #endif // OSDL_RUNS_ON_ARM9
00615
00616
00617 #else // OSDL_ARCH_NINTENDO_DS
00618
00619 throw CommandException( "CommandManager::fadeOutMusic failed: "
00620 "not available on this platform." ) ;
00621
00622 #endif // OSDL_ARCH_NINTENDO_DS
00623
00624 }
00625
00626
00627
00628 void CommandManager::setMusicVolume( Volume newVolume )
00629 {
00630
00631 #if OSDL_ARCH_NINTENDO_DS
00632
00633 #ifdef OSDL_RUNS_ON_ARM9
00634
00635
00636 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00637
00638 writeBlocking( prepareFIFOCommand( SetMusicVolumeRequest ) | newVolume ) ;
00639
00640 SetEnabledInterrupts( previous ) ;
00641
00642 notifyCommandToARM7() ;
00643
00644
00645 #else // OSDL_RUNS_ON_ARM9
00646
00647 throw CommandException( "CommandManager::setMusicVolume failed: "
00648 "not available on the ARM7." ) ;
00649
00650 #endif // OSDL_RUNS_ON_ARM9
00651
00652
00653 #else // OSDL_ARCH_NINTENDO_DS
00654
00655 throw CommandException( "CommandManager::setMusicVolume failed: "
00656 "not available on this platform." ) ;
00657
00658 #endif // OSDL_ARCH_NINTENDO_DS
00659
00660 }
00661
00662
00663
00664 void CommandManager::pauseMusic()
00665 {
00666
00667 #if OSDL_ARCH_NINTENDO_DS
00668
00669 #ifdef OSDL_RUNS_ON_ARM9
00670
00671
00672 if ( _currentMusic == 0 )
00673 return ;
00674
00675 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00676
00677 writeBlocking( prepareFIFOCommand( PauseMusicRequest ) ) ;
00678
00679 SetEnabledInterrupts( previous ) ;
00680
00681 notifyCommandToARM7() ;
00682
00683 #else // OSDL_RUNS_ON_ARM9
00684
00685 throw CommandException( "CommandManager::pauseMusic failed: "
00686 "not available on the ARM7." ) ;
00687
00688 #endif // OSDL_RUNS_ON_ARM9
00689
00690
00691 #else // OSDL_ARCH_NINTENDO_DS
00692
00693 throw CommandException( "CommandManager::pauseMusic failed: "
00694 "not available on this platform." ) ;
00695
00696 #endif // OSDL_ARCH_NINTENDO_DS
00697
00698 }
00699
00700
00701
00702 void CommandManager::unpauseMusic()
00703 {
00704
00705 #if OSDL_ARCH_NINTENDO_DS
00706
00707 #ifdef OSDL_RUNS_ON_ARM9
00708
00709
00710 if ( _currentMusic == 0 )
00711 return ;
00712
00713 InterruptMask previous = SetEnabledInterrupts( AllInterruptsDisabled ) ;
00714
00715 writeBlocking( prepareFIFOCommand( UnpauseMusicRequest ) ) ;
00716
00717 SetEnabledInterrupts( previous ) ;
00718
00719 notifyCommandToARM7() ;
00720
00721 #else // OSDL_RUNS_ON_ARM9
00722
00723 throw CommandException( "CommandManager::unpauseMusic failed: "
00724 "not available on the ARM7." ) ;
00725
00726 #endif // OSDL_RUNS_ON_ARM9
00727
00728
00729 #else // OSDL_ARCH_NINTENDO_DS
00730
00731 throw CommandException( "CommandManager::unpauseMusic failed: "
00732 "not available on this platform." ) ;
00733
00734 #endif // OSDL_ARCH_NINTENDO_DS
00735
00736 }
00737
00738
00739
00740 void CommandManager::notifyEndOfEncodedStreamReached()
00741 {
00742
00743 #if OSDL_ARCH_NINTENDO_DS
00744
00745 #ifdef OSDL_RUNS_ON_ARM9
00746
00747
00748
00749 writeBlocking( prepareFIFOCommand( EndOfEncodedStreamReached ) ) ;
00750
00751 notifyCommandToARM7() ;
00752
00753 #else // OSDL_RUNS_ON_ARM9
00754
00755 throw CommandException(
00756 "CommandManager::notifyEndOfEncodedStreamReached failed: "
00757 "not available on the ARM7." ) ;
00758
00759 #endif // OSDL_RUNS_ON_ARM9
00760
00761
00762 #else // OSDL_ARCH_NINTENDO_DS
00763
00764 throw CommandException(
00765 "CommandManager::notifyEndOfEncodedStreamReached failed: "
00766 "not available on this platform." ) ;
00767
00768 #endif // OSDL_ARCH_NINTENDO_DS
00769
00770 }
00771
00772
00773
00774 void CommandManager::unsetCurrentMusic( Music & music )
00775 {
00776
00777 if ( _currentMusic == &music )
00778 _currentMusic = 0 ;
00779
00780 }
00781
00782
00783
00784 string CommandManager::interpretLastARM7ErrorCode()
00785 {
00786
00787 ARM7ErrorCode error = getLastARM7ErrorCode() ;
00788
00789
00790 if ( error < 1024 )
00791 return FIFO::interpretLastARM7ErrorCode() ;
00792
00793 switch( error )
00794 {
00795
00796 case HelixInitializationFailed:
00797 return "Helix initialization failed "
00798 "(most probably not enough memory available on the ARM7)" ;
00799 break ;
00800
00801 case HelixSyncWordNotFound:
00802 return "Helix decoder could not find "
00803 "the next sync word in the mp3 stream" ;
00804 break ;
00805
00806 case HelixFoundTruncatedFrame:
00807 return "Helix decoder is out of data, "
00808 "found a truncated or last frame in the mp3 stream" ;
00809 break ;
00810
00811 case HelixLacksDataInBitReservoir:
00812 return "Helix decoder does not have enough data "
00813 "in bit reservoir from previous frames" ;
00814 break ;
00815
00816 case HelixLacksFreeBitrateSlot:
00817 return "Helix decoder lacks a free bitrate slot" ;
00818 break ;
00819
00820 case HelixDecodingError:
00821 return "Helix decoding failed" ;
00822 break ;
00823
00824 case HelixUnexpectedDecodedLength:
00825 return
00826 "Helix decoder found a decoded mp3 frame "
00827 "with an unexpected length" ;
00828 break ;
00829
00830 default:
00831 return "unexpected OSDL ARM7 error code ("
00832 + Ceylan::toString( error ) + ")" ;
00833 break ;
00834
00835 }
00836
00837 }
00838
00839
00840
00841 const string CommandManager::toString( Ceylan::VerbosityLevels level ) const
00842 {
00843
00844 string res = "Command manager based on " + FIFO::toString( level )
00845 + ". " ;
00846
00847 if ( _currentMusic == 0 )
00848 res += "No music currently playing" ;
00849 else
00850 res += "A music is currently playing: "
00851 + _currentMusic->toString() ;
00852
00853 return res ;
00854
00855 }
00856
00857
00858
00859
00860
00861
00862
00863
00864 bool CommandManager::HasExistingCommandManager()
00865 {
00866
00867 return _IPCManager != 0 ;
00868
00869 }
00870
00871
00872
00873 CommandManager & CommandManager::GetExistingCommandManager()
00874 {
00875
00876 if ( _IPCManager == 0 )
00877 throw CommandException( "CommandManager::GetExistingCommandManager: "
00878 "no manager available" ) ;
00879
00880 return *_IPCManager ;
00881
00882 }
00883
00884
00885
00886 CommandManager & CommandManager::GetCommandManager()
00887 {
00888
00889 if ( _IPCManager == 0 )
00890 _IPCManager = new CommandManager() ;
00891
00892 return *_IPCManager ;
00893
00894 }
00895
00896
00897
00898 void CommandManager::handleReceivedIntegratingLibrarySpecificCommand(
00899 FIFOCommandID commandID, Ceylan::System::FIFOElement firstElement )
00900 {
00901
00902
00903 #if OSDL_ARCH_NINTENDO_DS
00904
00905
00906 switch( commandID )
00907 {
00908
00909 case NoAvailableChannelNotification:
00910 LogPlug::warning(
00911 "No more free sound channel, playback cancelled" ) ;
00912 _currentMusic->managePlaybackEnded() ;
00913 break ;
00914
00915
00916
00917
00918
00919
00920
00921 case FirstBufferFillRequest:
00922 if ( _currentMusic != 0 )
00923 {
00924 try
00925 {
00926 _currentMusic->requestFillOfFirstBuffer() ;
00927
00928 }
00929 catch( const AudioException & e )
00930 {
00931
00932 LogPlug::error(
00933 "CommandManager::handleReceivedIntegratingLibrarySpecificCommand"
00934 " failed: " + e.toString() ) ;
00935
00936 }
00937 }
00938 else
00939 {
00940 LogPlug::error(
00941 "CommandManager::handleReceivedIntegratingLibrarySpecificCommand"
00942 " failed: request received for first buffer refill whereas "
00943 "no music is currently playing" ) ;
00944 }
00945 break ;
00946
00947 case SecondBufferFillRequest:
00948 if ( _currentMusic != 0 )
00949 {
00950 try
00951 {
00952 _currentMusic->requestFillOfSecondBuffer() ;
00953
00954 }
00955 catch( const AudioException & e )
00956 {
00957
00958 LogPlug::error(
00959 "CommandManager::handleReceivedIntegratingLibrarySpecificCommand"
00960 " failed: " + e.toString() ) ;
00961
00962 }
00963 }
00964 else
00965 {
00966 LogPlug::error(
00967 "CommandManager::handleReceivedIntegratingLibrarySpecificCommand"
00968 " failed: request received for second buffer refill whereas "
00969 "no music is currently playing" ) ;
00970 }
00971 break ;
00972
00973 case MusicEndedNotification:
00974 LogPlug::debug( "Music ended." ) ;
00975 if ( _currentMusic != 0 )
00976 _currentMusic->managePlaybackEnded() ;
00977 else
00978 LogPlug::error(
00979 "CommandManager::handleReceivedIntegratingLibrarySpecificCommand "
00980 "failed: notification of end of music received, but there is "
00981 "no current music" ) ;
00982 break ;
00983
00984 case MusicFrameInformation:
00985 LogPlug::debug( "Music frame informations: "
00986 + Ceylan::toString( firstElement & 0x0000ffff )
00987 + " output samples, "
00988 + Ceylan::toString( readBlocking() ) + " bytes read." ) ;
00989 break ;
00990
00991 default:
00992 LogPlug::error( "handleReceivedIntegratingLibrarySpecificCommand: "
00993 "unexpected command: " + Ceylan::toNumericalString( commandID )
00994 + ", ignored." ) ;
00995 break ;
00996
00997 }
00998
00999 #endif // OSDL_ARCH_NINTENDO_DS
01000
01001 }
01002