]> Chaos Git - corbenik/ctrulib.git/commitdiff
Add ndspChnIsPaused/ndspChnSetPaused (untested)
authorfincs <fincs.alt1@gmail.com>
Thu, 28 Jan 2016 22:46:03 +0000 (23:46 +0100)
committerfincs <fincs.alt1@gmail.com>
Thu, 28 Jan 2016 22:46:03 +0000 (23:46 +0100)
libctru/include/3ds/ndsp/channel.h
libctru/source/ndsp/ndsp-channel.c

index fa9229516fafbb712c5e07913933d575e890cc9c..443725c8ac3c38a0369d0a8ea85c1973b2902d3c 100644 (file)
@@ -81,6 +81,21 @@ u32  ndspChnGetSamplePos(int id);
  * @return The sequence ID of the wave buffer.
  */
 u16  ndspChnGetWaveBufSeq(int id);
+
+/**
+ * @brief Checks whether a channel is currently paused.
+ * @param id ID of the channel (0..23).
+ * @return Whether the channel is currently paused.
+ */
+bool ndspChnIsPaused(int id);
+
+/**
+ * @brief Sets the pause status of a channel.
+ * @param id ID of the channel (0..23).
+ * @param paused Whether the channel is to be paused (true) or unpaused (false).
+ */
+void ndspChnSetPaused(int id, bool paused);
+
 ///@}
 
 ///@name Configuration
index d7c709f864ab5b393df8e6d17512e31c46060fc4..d9437eeb4af0db4793975eee32e03110fcac578d 100644 (file)
@@ -24,7 +24,7 @@ typedef struct
        ndspWaveBuf* waveBuf;
        u16 wavBufCount, wavBufIdNext;
 
-       bool playing;
+       bool playing, paused;
        u8 interpType, iirFilterType;
 
        u16 format;
@@ -52,6 +52,7 @@ void ndspChnReset(int id)
        chn->wavBufIdNext = 0;
        chn->wavBufSeq = 0;
        chn->playing = false;
+       chn->paused = false;
        chn->interpType = 0;
        chn->iirFilterType = 0;
        chn->format = NDSP_FORMAT_PCM16;
@@ -89,6 +90,20 @@ void ndspChnSetFormat(int id, u16 format)
        ndspChn[id].format = format;
 }
 
+bool ndspChnIsPaused(int id)
+{
+       return ndspChn[id].paused;
+}
+
+void ndspChnSetPaused(int id, bool paused)
+{
+       ndspChnSt* chn = &ndspChn[id];
+       LightLock_Lock(&chn->lock);
+       chn->paused = paused;
+       chn->flags |= CFLAG_PLAYSTATUS;
+       LightLock_Unlock(&chn->lock);
+}
+
 void ndspChnSetInterp(int id, ndspInterpType type)
 {
        ndspChnSt* chn = &ndspChn[id];
@@ -336,7 +351,7 @@ void ndspiUpdateChn(void)
                if (flags & CFLAG_PLAYSTATUS)
                {
                        u16 playStatus = st->playStatus &~ 0xFF;
-                       if (chn->playing)
+                       if (chn->playing && !chn->paused)
                                playStatus |= 1;
                        st->playStatus = playStatus;
                        stflags |= 0x10000;